package com.t235.gc.device.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.t235.gc.AjaxResult;
import com.t235.gc.device.service.SysManagerService;
import com.t235.gc.entity.SysManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/manager")
public class SysManagerController {

    @Autowired
    private SysManagerService sysManagerService;

    @GetMapping("/admin/getSortingOrOperatorsList")
    public AjaxResult getSortingOrOperatorsList(SysManager sysManager, @RequestParam(value = "page",defaultValue = "0")Integer pageNo, @RequestParam(value = "limit",defaultValue = "2")Integer pageSize) throws Exception{
        PageHelper.startPage(pageNo,pageSize);
        List<SysManager> cs = sysManagerService.getSortingOrOperatorsList(sysManager);
        PageInfo<SysManager> pageInfo = new PageInfo<>(cs);
        return AjaxResult.success(pageInfo);
    }

    @GetMapping("/admin/getManagerList")
    public AjaxResult getManagerList(SysManager sysManager){
        return AjaxResult.success(sysManagerService.getManagerList(sysManager));
    }
}
